package cz.muni.fi.pa165.musiclibrary.impl.service.dto;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.joda.time.Duration;

import cz.muni.fi.pa165.musiclibrary.api.service.dto.IAlbumDTO;
import cz.muni.fi.pa165.musiclibrary.api.service.dto.IArtistDTO;
import cz.muni.fi.pa165.musiclibrary.api.service.dto.IGenreDTO;
import cz.muni.fi.pa165.musiclibrary.api.service.dto.ISongDTO;

/**
 *
 * @author Martin Majlath 2012-10-28T19:52:30+0100
 */
public final class SongDTO implements ISongDTO {

    /**
     * Identifier of this song.
     */
    private Long idSong;
    
    /**
     * Artist of this song.
     */
    private IArtistDTO artist;
    
    /**
     * Genre of this song.
     */
    private IGenreDTO genre;
    /**
     * Album of this song.
     */
    private IAlbumDTO album;
    /**
     * Title of this song.
     */
    private String title;
    /**
     * Bitrate of this song.
     */
    private Integer bitrate;
    /**
     * Duration of this song.
     */
    private Duration length;
    /**
     * Position on album of this song
     */
    private Integer trackNumber;
    /**
     * Description or comment for this song
     */
    private String comment;

    @Override
    public Long getIdSong() {
        return idSong;
    }

    @Override
    public IGenreDTO getGenre() {
        return genre;
    }

    @Override
    public IAlbumDTO getAlbum() {
        return album;
    }
    
    @Override
    public IArtistDTO getArtist() {
        return artist;
    }

    @Override
    public String getTitle() {
        return title;
    }

    @Override
    public Integer getBitrate() {
        return bitrate;
    }

    @Override
    public Duration getLength() {
        return length;
    }

    @Override
    public Integer getTrackNumber() {
        return trackNumber;
    }

    @Override
    public String getComment() {
        return comment;
    }

    @Override
    public void setIdSong(Long idSong) {
        this.idSong = idSong;
    }

    @Override
    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public void setBitrate(Integer bitrate) {
        this.bitrate = bitrate;
    }

    @Override
    public void setLength(Duration length) {
        this.length = length;
    }

    @Override
    public void setTrackNumber(Integer trackNumber) {
        this.trackNumber = trackNumber;
    }

    @Override
    public void setComment(String comment) {
        this.comment = comment;
    }

    @Override
    public void setArtist(IArtistDTO artist) {
        this.artist = artist;
    }
    
    @Override
    public void setGenre(IGenreDTO genre) {
        this.genre = genre;
    }

    @Override
    public void setAlbum(IAlbumDTO album) {
        this.album = album;
    }
    
    /**
     * Implemented using {@link EqualsBuilder}.
     * 
     * {@inheritDoc }
     */
    @Override
    public boolean equals(final Object obj) {
        if (obj == null || !(obj instanceof ISongDTO)) {
            return false;
        }
        
        final ISongDTO other = (ISongDTO) obj;
        return new EqualsBuilder()//
                .append(this.getIdSong(), other.getIdSong())//
                .build();
    }

    /**
     * Implemented using {@link HashCodeBuilder}.
     * 
     * {@inheritDoc }.
     */
    @Override
    public int hashCode() {
        return new HashCodeBuilder()//
                .append(this.getIdSong())//
                .build();
    }
    
    /**
     * Implemented using {@link ToStringBuilder#reflectionToString(java.lang.Object, org.apache.commons.lang3.builder.ToStringStyle) }
     * with second argument {@link ToStringStyle#MULTI_LINE_STYLE}.
     */
    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    }
}